# 财经日历 网络请求 时间缓存
NET_REQUEST_TIME = 0

# tradeview 网络请求 时间缓存
NET_TREAD_TIME = 0

# 搜狐财经日历
SOUHU_WEB_URL = "http://vip.stock.finance.sina.com.cn/forex/api/jsonp.php/SINAFINANCE15463145567419148" \
                "/DailyFX_AllService.getOnedayEventsNew?date="

# tradeview 动态数据
TRADR_VIEW_URL = "https://www.tradingview.com/symbols/TVC-GOLD/technicals/"

# tradeview 静态数据
TRADE_PAGE_URL = "https://www.tradingview.com/symbols/TVC-GOLD/ideas/"

# 汇通网策略
TRADE_HUITONG_URL = "https://gold.fx678.com/"

# 邮件发送时间间隔
EMAIL_SEND_TIME = 15

# 下单点位  从文章中提取
MAJOY_POINT = ""

# tradeview 市场情绪
TRADE_FEEL = ""

# 汇通网交易策略
HUITONG_POINT = ""
HT_CELVE = ""

# 搜狐财经
CAIJING_SH = []

# 交易点位
TRADE_POINT = []


def get_souhu_url(time):
    return SOUHU_WEB_URL + time + "&rn=1546314556741"


def set_global_value(value, type=0):
    if type == 0:
        global NET_REQUEST_TIME
        NET_REQUEST_TIME = value

    if type == 1:
        global NET_TREAD_TIME
        NET_TREAD_TIME = value


def get_global_value(type=0):
    if type == 0:
        global NET_REQUEST_TIME
        return NET_REQUEST_TIME

    if type == 1:
        global NET_TREAD_TIME
        return NET_TREAD_TIME


def getPoint():
    global MAJOY_POINT
    return MAJOY_POINT


def setPoint(value):
    global MAJOY_POINT
    MAJOY_POINT = value


def getTradefeel():
    global TRADE_FEEL
    return TRADE_FEEL


def setTradefeel(value):
    global TRADE_FEEL
    TRADE_FEEL = value


def getHtPoint():
    global HUITONG_POINT
    return HUITONG_POINT


def setHtPoint(value):
    global HUITONG_POINT
    HUITONG_POINT = value


def getCelve():
    global HT_CELVE
    return HT_CELVE


def setCelve(value):
    global HT_CELVE
    HT_CELVE = value


def getShCaijing():
    global CAIJING_SH
    return CAIJING_SH


def setShCaijing(value):
    global CAIJING_SH
    CAIJING_SH = value


def getTradePoint():
    global TRADE_POINT
    return TRADE_POINT


def setTradePoint(value):
    global TRADE_POINT
    TRADE_POINT = value


def socketMes():
    '''
    1：低多
    2：高空
    3：震荡
    :return:
    '''

    a = getCelve()  # 汇通网策略信息
    b = getPoint()  # 从文章提取的点位信息
    c = getTradefeel()  # tradeview市场情绪

    if len(a) != 0 and len(b) != 0 and len(c) != 0:
        strArr = c.split(",")
        sell = int(strArr[0])
        buy = int(strArr[1])
        nomal = int(strArr[2])

        if (('逢低' in a) and ('逢高' in a)) and (sell < 45 and buy < 45):
            return "3|" + b
        elif ('逢高' in a) and (sell > 55 and buy < 15):
            return "2|" + b
        elif ('逢低' in a) and (buy > 55 and sell < 15):
            return "1|" + b
        else:
            return "null"
    return "null"
